From : S.E. Morris (S.E.Morris@csc.liv.ac.uk)
Subject : Blitting a shape in different colors
With regards to the problem of blitting the same shape with different colours
without using loads of different shapes...
Has anyone suggested using the shapes bitplanes to determine the colour...?
This requires the palette be layed out in a particular order, but apart from
this it shouldn't cause any problems: it still requires the same number of
paletter enteries, except they must now be in a specific order.
Lets assume you have a 32 colour display. Lets also assume that the
basic shape you wish to plot is 8 colours, and there are 4 different
coloured objects in the game, thus 8 x 4 = 32 colours.
When we blit the shape, if we blit the lower 3 bits of each pixel using
the shape data (remember, 8 colours = 3 bitplanes), and then use the highest
2 bits to determine which 'bank' of 8 colours in our 32 to use, we can
re-use the same shape image for all 4 different coloured objects.
You'll need a blitting routine which blits the 3 bitplanes, and then
allows you to blit either the shape's cookie-cut (mask) or zeros into the
remaining bitplanes to determine the bank... Mind you, that's easier said
than done :->
This is (AFAIK) the most efficient way to do it, but it's certainly not
recommended for those uneducated in the workings of the blitter.